package com.dhsc.service.impl.xtqxgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhsc.domain.ywzx.xtqxgl.XtqxlsVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.xtqxgl.IXtqxlsDao;
import com.dhsc.service.xtqxgl.IXtqxlsService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: XtqxlsServiceImpl
 * @Description: 系统权限流水
 * @date: 2023/11/21 9:41
 * @author: gx
 */
@Service
@Slf4j
public class XtqxlsServiceImpl implements IXtqxlsService {

    @Autowired
    private IXtqxlsDao xtqxlsDao;

    @Override
    public LayuiTableVo queryXtqxls(XtqxlsVo xtqxlsVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            PageMethod.startPage(xtqxlsVo.getPage(), xtqxlsVo.getLimit());
            List<XtqxlsVo> list = xtqxlsDao.queryXtqxls(xtqxlsVo);
            PageInfo<XtqxlsVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch (Exception e){
            log.error("查询系统权限流水信息出错",e);
            throw new MyException("查询系统权限流水信息出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject updateXtqxlsPass(XtqxlsVo xtqxlsVo) {
        ResponseObject obj = new ResponseObject();
        try {
            xtqxlsDao.updateXtqxlsPass(xtqxlsVo);
            obj.setStatus(200);
        } catch (Exception e) {
            log.error("复核通过出错", e);
            throw new MyException("复核通过出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject updateXtqxlsReturn(XtqxlsVo xtqxlsVo) {
        ResponseObject obj = new ResponseObject();
        try {
            xtqxlsDao.updateXtqxlsReturn(xtqxlsVo);
            obj.setStatus(200);
        } catch (Exception e) {
            log.error("复核退回出错", e);
            throw new MyException("复核退回出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryXtyh(XtqxlsVo xtqxlsVo) {
        ResponseObject obj = new ResponseObject();
        try {
            List<XtqxlsVo> list = xtqxlsDao.queryXtyh(xtqxlsVo);
            obj.setData(list);
            obj.setStatus(200);
        } catch (Exception e) {
            log.error("查询系统用户出错", e);
            throw new MyException("查询系统用户出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject updateXtyh(XtqxlsVo xtqxlsVo) {
        ResponseObject obj = new ResponseObject();
        try {
            xtqxlsDao.updateXtyh(xtqxlsVo);
            obj.setStatus(200);
        } catch (Exception e) {
            log.error("分配用户出错", e);
            throw new MyException("分配用户出错",e);
        }
        return obj;
    }
}
